package com.slz3.business.module.systemManagement.sysPermissions.domain;

import com.slz3.business.frame.enums.AuditFlag;
import com.slz3.business.frame.enums.UsingFlag;
import com.slz3.business.frame.util.UUIDUtils;
import com.slz3.business.frame.util.VE;

import java.time.LocalDateTime;

public class SysPermissionsFactory {

    /**
     * 初始化基础属性值
     */
    public static SysPermissions initBaseFields(SysPermissions sysPermissions) {
        if (sysPermissions.getUuid() == null) {
            sysPermissions.setUuid(UUIDUtils.generateUUID());
            sysPermissions.setCreateTime(LocalDateTime.now());
            sysPermissions.setSerAudit(AuditFlag.APPROVED);
            if (VE.isEmpty(sysPermissions.getSerUsing())) {
                sysPermissions.setSerUsing(UsingFlag.ENABLE);
            }
        } else {
            sysPermissions.setLastModifyTime(LocalDateTime.now());
        }
        return sysPermissions;
    }

    /**
     * 初始化基础属性值
     */
    public static SysPermissions initBaseFields() {
        return initBaseFields(newTemStyle());
    }

    public static SysPermissions newTemStyle() {
        return new SysPermissions();
    }

}
